package com.candy.servlet;

import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.demoweb.model.dao.BoardDao;

import com.demoweb.model.dto.Board;

import com.demoweb.ui.ThePager;

@WebServlet("/candy/itemview.action")
public class ItemViewServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;

	protected void doGet(HttpServletRequest request,
			HttpServletResponse response) throws ServletException, IOException {

		// 1. 목록 페이지에서 사용자가 선택한 자료번호를 읽고 변수에 저장
//		// (자료번호가 없으면 목록으로 이동)
//		if (request.getParameter("uploadno") == null || request.getParameter("uploadno").length() == 0) {
//			response.sendRedirect("list.action");
//			return;
//		}
//
//		int uploadNo = Integer.parseInt(request.getParameter("uploadno"));
//
//		// 2. 자료번호로 데이터 조회 (조회 실패하면 목록으로 이동)
//		UploadDao dao = new UploadDao();
//		Upload upload = dao.getUploadByUploadNo(uploadNo);
//		if (upload == null) {
//			response.sendRedirect("list.action");
//			return;
//		}
//
//		dao.increaseUploadReadCount(uploadNo);// 조회수 증가
//		
//		request.setAttribute("upload", upload);
		
		RequestDispatcher dispatcher = 
			request.getRequestDispatcher("/WEB-INF/views/candy/candyitemlist.jsp");

		dispatcher.forward(request, response);

	}

	protected void doPost(HttpServletRequest request,
			HttpServletResponse response) throws ServletException, IOException {
		doGet(request, response);
	}

}
